<?php

class NavigationView {
	
	/**
	 * URL string for when user wants to logout.
	 * @var String
	 */
	private static $logoutURL = "logout";
	
	/**
	 * URL string for when user wants to login.
	 * @var String
	 */
	private static $loginURL = "login";
	private static $registerURL = "register";
	private static $usernameURL = "username";
	private static $userWasRegistered = "userWasRegistered";
	
	/**
	 * @param array $userList User
	 * @var string $str HTML
	 * @return string HTML
	 */
	public function getDropDownBox ($userList) {
		$str = "<select class='DropDown' onchange='javascript:location.href = this.value;'>";
		$str .= "<option value=''></option>";
		
		foreach ($userList as $user) {
			$str .= "<option value='?". $this->getUsernameURL() ."=". $user->getUsername() ."'>". $user->getUsername() ."</option>";
		}
		
		return $str .= "</select>";
	}
	
	/**
	 * @return boolean
	 */
	public function userWantsToLogIn() {
		return isset($_GET[self::$loginURL]);
	}
	
	/**
	 * @return string ----------------------------------------------------------------------------------------------------------
	 */
	public function getLoginURL() {
		return self::$loginURL;
	}
	
	public function getLogoutURL() {
		return self::$logoutURL;
	}
	
	public function getRegisterURL() {
		return self::$registerURL;
	}
	
	public function getUsernameURL() {
		return self::$usernameURL;
	}
	
	public function getUserWasRegisteredURL() {
		return self::$userWasRegistered;
	}
	
	public function getCurrentUsername() {
		if (isset($_GET[self::$usernameURL])) {
			return $_GET[self::$usernameURL];
		}
		return "";
	}
	
	public function getUserWasRegisteredUsername() {
		if (isset($_GET[self::$userWasRegistered])) {
			return $_GET[self::$userWasRegistered];
		}
		return "";
	}
	
	/**
	 * @return boolean ---------------------------------------------------------------------------------------------------------
	 */
	public function userWantsToLogout() {
		return isset($_GET[self::$logoutURL]);
	}
	
	public function userWantsToShowRegister() {
		return isset($_GET[self::$registerURL]);
	}
	
	public function userWasRegistered() {
		return isset($_GET[self::$userWasRegistered]);
	}
}
